// Package wire
/**
* @Project : geektime-basic-go-study
* @File    : main.go
* @IDE     : GoLand
* @Author  : Tvux
* @Date    : 2024/10/7 20:50
**/

package wire

import (
	"fmt"
	"geektime-basic-go-study/webook/backend/config"
	"geektime-basic-go-study/wire/repository"
	"geektime-basic-go-study/wire/repository/dao"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
)

// 普通的依赖注入写法，会有复杂冗长的构造链表
func main() {
	db, err := gorm.Open(mysql.Open(config.Config.DBConf.DSN))
	if err != nil {
		panic(err)
	}
	userDao := dao.NewUserDAO(db)
	userRepo := repository.NewUserRepository(userDao)
	fmt.Println(userRepo)
}
